﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Expense.aspx.cs" Inherits="TestHT.Operations.Expense"
    Theme="Theme1" MasterPageFile="~/DefaultHT.Master" %>


<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <link rel="stylesheet" href="../Styles/Main.css" type="text/css" />
    <link rel="stylesheet" href="../Scripts/css/jquery.ui.all.css" type="text/css">
    <link rel="stylesheet" href="../Scripts/css/jquery.ui.theme.css" type="text/css">
    <script src="../Scripts/jquery-1.8.2.js"></script>
    <script src="../Scripts/jquery-1.4.1.min.js"></script>
    <script src="../Scripts/jquery.ui.core.js"></script>
    <script src="../Scripts/jquery.ui.widget.js"></script>
    <script src="../Scripts/jquery.ui.datepicker.js"></script>
        <link rel="stylesheet" href="../Scripts/css/demos.css" type="text/css">
    <script type="text/javascript">


        $(function () {
            $("input[id$='txtStartDate']").datepicker({
                // defaultDate: "+1w",
                changeYear: true,
                changeMonth: true,
                // numberOfMonths: 3,
                onSelect: function (selectedDate) {
                    $("input[id$='txtEndDate']").datepicker("option", "minDate", selectedDate);
                }
            });
            $("input[id$='txtEndDate']").datepicker({
                // defaultDate: "+1w",
                changeMonth: true,
                changeYear: true,
                //numberOfMonths: 3,
                onSelect: function (selectedDate) {
                    $("input[id$='txtStartDate']").datepicker("option", "maxDate", selectedDate);
                }
            });

            $("input[id$='txtDate']").datepicker({
                // defaultDate: "+1w",
                changeMonth: true,
                changeYear: true,
                onSelect: function (selectedDate) {


                }
            });
            $('.date').datepicker({
                // defaultDate: "+1w",
                changeMonth: true,
                changeYear: true,
                onSelect: function (selectedDate) {


                }
            });

            $("#btnSubmit").click(function () {
                var sDate = Date.parse($("input[id$='txtStartDate']").val());
                var eDate = Date.parse($("input[id$='txtEndDate']").val());
                if (sDate > eDate) {
                    alert('start date cannot be greater than end date');
                    return false;
                }

            });



        });

    </script>
      <div style="height: 30px; padding: 10px 10px 10px 10px;">
		<h2>Expense</h2>
	</div>
    <div style="text-align: center;padding-left:10px;">
            <asp:Table ID="tableSearch" runat="server">
                <asp:TableRow>
                    <asp:TableCell>Start Date</asp:TableCell>
                    <asp:TableCell>
                        <div class="demo">
                            <asp:TextBox ID="txtStartDate" runat="server" CssClass="textbox"></asp:TextBox>
                        </div>
                    </asp:TableCell>
                    <asp:TableCell>End Date</asp:TableCell>
                    <asp:TableCell>
                        <div class="demo">
                            <asp:TextBox ID="txtEndDate" runat="server" CssClass="textbox"></asp:TextBox>
                        </div>
                    </asp:TableCell>
                    <asp:TableCell>
                        <asp:Button ID="btnSubmit" runat="server" Text="Go" OnClick="btnSumbit_click" />
                    </asp:TableCell>
                </asp:TableRow>
            </asp:Table>
            <asp:GridView ID="gvExpense" runat="server" AutoGenerateColumns="false" CssClass="grid" AlternatingRowStyle-CssClass="gridAltRow"
                RowStyle-CssClass="gridRow" ShowFooter="True" EditRowStyle-CssClass="gridEditRow"
                FooterStyle-CssClass="gridFooterRow" OnRowCancelingEdit="gvExpense_RowCancelingEdit"
                OnRowCommand="gvExpense_RowCommand" OnRowDeleting="gvExpense_RowDeleting" OnRowUpdating="gvExpense_RowUpdating"
                DataKeyNames="ExpenseId" OnRowEditing="gvExpense_RowEditing">
                <Columns>
                    <asp:TemplateField HeaderText="Expense Date">
                        <ItemTemplate>
                            <asp:Label ID="lblDate" runat="server" Text='<%#Eval("ExpenseDate","{0:d}")%>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <div class="demo">
                            <asp:TextBox ID="txtDate1" runat="server" CssClass="textbox date" Text='<%#Eval("ExpenseDate","{0:d}")%>'></asp:TextBox></div>
                            <asp:RequiredFieldValidator ID="rftxtDate" runat="server" ControlToValidate="txtDate1" ErrorMessage="Expense Date is required." ValidationGroup="Update" Display="None"></asp:RequiredFieldValidator>
                        </EditItemTemplate>
                        <FooterTemplate>
                            <div class="demo">
                            <asp:TextBox ID="txtDate" runat="server" CssClass="textbox "></asp:TextBox></div>
                            <asp:RequiredFieldValidator ID="rfDate" runat="server" ControlToValidate="txtDate" ErrorMessage="Expense Date is required." ValidationGroup="Insert"></asp:RequiredFieldValidator>
                        </FooterTemplate>
                        <ItemStyle HorizontalAlign="Center" VerticalAlign="Top"/>
                        
                        <FooterStyle  HorizontalAlign="Center"/>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Expense Description">
                        <ItemTemplate>
                            <asp:Label ID="lblExpenseDescription" runat="server" Text='<%#Eval("ExpenseDescription")%>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="txExpenseDescription" runat="server" CssClass="textbox" Text='<%#Eval("ExpenseDescription")%>'></asp:TextBox>
                            <asp:RequiredFieldValidator ID="rftxExpenseDescription" runat="server" ControlToValidate="txExpenseDescription" ErrorMessage="Description  is required." ValidationGroup="Update" Display="None"></asp:RequiredFieldValidator>
                        </EditItemTemplate>
                        <FooterTemplate>
                            <asp:TextBox ID="txtExpenseDescription" runat="server" CssClass="textbox"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="rfExpenseDescription" runat="server" ControlToValidate="txtExpenseDescription" ErrorMessage="Description  is required." ValidationGroup="Insert" Display="None"></asp:RequiredFieldValidator>
                        </FooterTemplate>
                        <ItemStyle HorizontalAlign="Left" />
                           <FooterStyle  HorizontalAlign="Left" VerticalAlign="Top"/>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Amount">
                        <ItemTemplate>
                            <asp:Label ID="lblAmount" runat="server" Text='<%#Eval("Amount","{0:n2}")%>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="txtAmount" runat="server" CssClass="textbox" Text='<%#Eval("Amount","{0:n2}")%>'></asp:TextBox>
                            <asp:RequiredFieldValidator ID="rftxtAmount" runat="server" ControlToValidate="txtAmount" ErrorMessage="Amount is required." ValidationGroup="Update" Display="None"></asp:RequiredFieldValidator>
                        </EditItemTemplate>
                        <FooterTemplate>
                            <asp:TextBox ID="txtAmount" runat="server" CssClass="textbox"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="rfAmount" runat="server" ControlToValidate="txtAmount" ErrorMessage="Amount is required." ValidationGroup="Insert" Display="None"></asp:RequiredFieldValidator>
                        </FooterTemplate>
                        <ItemStyle HorizontalAlign="Right"/>
                           <FooterStyle  HorizontalAlign="Right" VerticalAlign="Top"/>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Remarks">
                        <ItemTemplate>
                            <asp:Label ID="lblRemarks" runat="server" Text='<%#Eval("Remarks")%>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="txtRemarks" runat="server" CssClass="textbox" Text='<%#Eval("Remarks")%>'></asp:TextBox>

                        </EditItemTemplate>
                        <FooterTemplate>
                            <asp:TextBox ID="txtRemarks" runat="server" CssClass="textbox"></asp:TextBox>
                        </FooterTemplate>
                        <ItemStyle  HorizontalAlign="Left"/>
                        <FooterStyle  HorizontalAlign="Left" VerticalAlign="Top"/>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="" ShowHeader="False" HeaderStyle-HorizontalAlign="Left">
                        <EditItemTemplate>
                            <asp:LinkButton ID="lnkUpdate" runat="server" CausesValidation="True" CommandName="Update"
                                Text="Update" OnClientClick="return confirm('Update?')" ValidationGroup="Update"></asp:LinkButton>
                            <asp:ValidationSummary ID="vsUpdate" runat="server" ShowMessageBox="true" ShowSummary="false"
                                ValidationGroup="Update" Enabled="true" HeaderText="Validation Summary..." />
                            <asp:LinkButton ID="lnkCancel" runat="server" CausesValidation="False" CommandName="Cancel"
                                Text="Cancel"></asp:LinkButton>
                        </EditItemTemplate>
                        <FooterTemplate>
                            <asp:LinkButton ID="lnkAdd" runat="server" CausesValidation="True" CommandName="Insert"
                                ValidationGroup="Insert" Text="Save"></asp:LinkButton>
                            <asp:ValidationSummary ID="vsInsert" runat="server" ShowMessageBox="true" ShowSummary="false"
                                ValidationGroup="Insert" Enabled="true" HeaderText="Validation..." />
                        </FooterTemplate>
                        <ItemTemplate>
                            <asp:LinkButton ID="lnkEdit" runat="server" CausesValidation="False" CommandName="Edit"
                                Text="Edit"></asp:LinkButton>
                        </ItemTemplate>
                        <HeaderStyle HorizontalAlign="Left" />
                          <FooterStyle  HorizontalAlign="Left" VerticalAlign="Top"/>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Delete" ShowHeader="False" HeaderStyle-HorizontalAlign="Left" Visible="false">
                        <ItemTemplate>
                            <asp:LinkButton ID="lnkDelete" runat="server" CausesValidation="False" CommandName="Delete"
                                Text="Delete" OnClientClick="return confirm('Delete?')"></asp:LinkButton>
                        </ItemTemplate>
                        <HeaderStyle HorizontalAlign="Left" />
                    </asp:TemplateField>

                </Columns>
            </asp:GridView>
        </div>
</asp:Content>
